<div id="top-panel">
    <div id="panel">
        <ul>
            <li><a href="<?php echo site_url("answer/create"); ?>" class="report">Create</a></li>            	
        </ul>
    </div>
</div>
<script language="javascript">
	var jq = jQuery.noConflict();
	jq(document).ready(function(){
		jq("#question_id").change(function(){
			var val = jq(this).val();
			if( val !=0 ){
				var url = jq("#form_filter").attr("action");
				document.location=url+"/"+val;
			}
			else{
				window.location = jq('a.hidden-link').attr('href');
			}
		});	
	});
</script>
<div id="wrapper">
	<div id="content">
		
		<div id="rightnow">
			<h3 class="reallynow">Answer list</h3>
			
			<div class="search_wrap">
				<div style="float:left;">
					<?php echo form_open('answer/search', array('class'=>'form_search')) ?>
					Search: <input type="text" name="search_text" id="search_text" class="input" />
					<?php echo form_close(); ?>
				</div>
				
				<div style="float:left;">
					<?php echo form_open('answer/filter', array('class'=>'form_search', 'id'=>'form_filter')) ?>
					
					Filter by: <select name="question_id" id="question_id" class="input1">
								<option value="0">All</option>
								<?php if(count($question)>0): ?>
								<?php foreach($question as $v): ?>
									<optgroup label="<?php echo $v['title']; ?>">
										<?php if(count($v['quest'])): ?>
										<?php foreach($v['quest'] as $i): ?>
											<option value="<?php echo $i['id']; ?>" <?php if(isset($q_id) && $q_id==$i['id']):?> selected="selected" <?php endif; ?>><?php echo $i['question']; ?></option>
										<?php endforeach; ?>
										<?php endif;?>
									</optgroup>								
								<?php endforeach; ?>
								<?php endif; ?>
							</select>
					<?php echo form_close(); ?>
				</div>
				<div style="clear:both;"></div>
			</div>
			
			<?php if (count($answer)): ?>
			<table width="100%">
				<thead>
					<tr>
						<th>Answer</th>	
						<th>Question</th>
						<th>Game</th>
						<th>Mark</th>
						<th>Task</th>					
					</tr>
				</thead>
				<tbody>
					<?php foreach($answer as $v): ?>
					<tr>
						<td><div style="padding-left:10px;"><a class="tool" href="<?php echo site_url("answer/edit/".$v['id']); ?>"><?php echo $v['answer']; ?></a></div></td>
						<td><div style="padding-left:10px;"><?php echo $v['question']; ?></div></td>
						<td><div style="padding-left:10px;"><?php echo $v['title']; ?></div></td>
						<td><div align="center"><?php echo $v['mark']; ?></div></td>
						<td><div align="center"><a class="tool" href="<?php echo site_url("answer/delete/".$v['id']); ?>">Delete</a></div></td>
					</tr>
					<?php endforeach; ?>
				</tbody>
			</table>
			<div id="pager">
				<?php echo $this->pagination->create_links(); ?>
			</div>
			<?php else: ?>
				<p>No data to display</p>
			<?php endif; ?>
			<a href="<?php echo site_url('answer'); ?>" class="hidden-link" style="display:none;"></a>
		</div>
	</div>
</div>